package com.mf.controller;


import com.mf.groups.GroupsAddInterface;
import com.mf.groups.GroupsUpdateInterface;
import com.mf.result.Result;
import com.mf.utils.UtilConverter;
import com.mf.entity.req.publicReq.ReqPublicIds;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;


import com.mf.entity.dto.DtoSortOut;
import com.mf.entity.req.ReqSortOut;
import com.mf.service.ServiceSortOut;
import com.mf.entity.req.search.SearchReqSortOut;

import java.util.List;

/**
 * 分拣产出明细
 * @date 2025-04-21 09:19:55
 */
@RestController
@RequestMapping("sortout")
@Tag(name = "分拣产出明细")
public class ControllerSortOut {
    @Resource
    private ServiceSortOut servicesortOut;

    @Operation(summary = "分页列表查询")
    @PostMapping("/page")
    public Result<Page<DtoSortOut>> findPage(@RequestBody SearchReqSortOut searchReqSortOut) {
        return Result.success(servicesortOut.findPageByParams(searchReqSortOut));
    }

    @Operation(summary = "列表查询")
    @PostMapping("/list")
    public Result<List<DtoSortOut>> list(@RequestBody SearchReqSortOut searchReqSortOut) {
        return Result.success(servicesortOut.findListByParams(searchReqSortOut));
    }

    @Operation(summary = "保存")
    @PostMapping("/save")
    public Result<Void> save(@Validated(GroupsAddInterface.class) @RequestBody ReqSortOut reqSortOut) {
        servicesortOut.save(UtilConverter.convert(reqSortOut, DtoSortOut.class));
        return Result.success();
    }


    @Operation(summary = "删除")
    @PostMapping("/delete/{id}")
    public Result<Void> delete(@PathVariable("id") Integer id) {
        servicesortOut.removeById(id);
        return Result.success();
    }

}
